Skip to content

Conversation

@joemsak
Copy link
Contributor

@joemsak joemsak commented Jan 23, 2026

Summary

  • This is pre-existing code in our primary monolith, being moved here
  • Add CodeTeams::Testing module for creating in-memory teams in tests without writing YML files to disk
  • Add CodeTeams::RSpecHelpers with code_team_with_config helper method
  • Activation is opt-in via CodeTeams::Testing.enable! which registers RSpec hooks for cleanup and includes helpers

Usage

# In spec_helper.rb
require 'code_teams/testing'

CodeTeams::Testing.enable!

Why

Extracts pre-existing test helpers from Gusto's monolith, making them reusable for any code_teams consumer after the next release.

Type signature improvements

While adding the new code, I noticed opportunities to reduce T.untyped usage across the codebase:

  • Utils now has typed: strict with proper signatures for underscore, demodulize, and deep_stringify_keys
  • Plugin.inherited(base) now typed as T.class_of(Plugin) instead of T.untyped
  • raw_hash now typed as T::Hash[String, T.untyped] since YAML parsing produces string keys
  • create_code_team attributes typed as T::Hash[Symbol, T.untyped] since callers pass symbol keys
  • Added T.must(name) in Plugin.default_data_accessor_name because Class#name returns T.nilable(String) (anonymous classes have nil names), but Plugin subclasses are always named

Adds an opt-in testing helper for creating in-memory teams and exposing them via
CodeTeams.all/find.
Provides an opt-in RSpec helper (code_team_with_config) and per-example cleanup
for in-memory teams.
Stop auto-including CodeTeams::RSpecHelpers; clients can include it in their own
RSpec config. The testing integration remains opt-in via requiring code_teams/rspec.
Move RSpec configuration into enable! method so clients explicitly
opt-in rather than having it auto-run on require. This gives consumers
control over when testing infrastructure is activated.
Specs now call CodeTeams::Testing.enable! at the top level before
RSpec.describe, matching the intended client usage pattern.
Document how to use code_teams/rspec and Testing.enable! for
creating temporary teams in specs.
This eliminates the conditional check for RSpecHelpers and simplifies
client usage - they only need to require code_teams/testing.
File name now matches the module it defines.
Consolidates utility methods in one place.
- Add typed: strict sigil and signatures to Utils
- Use T::Hash[Symbol, T.untyped] for create_code_team attributes
- Fix nilable string handling in Plugin.default_data_accessor_name
These belong in .git/info/exclude, not in the repo.
The enable! around hook handles cleanup automatically.
- inherited(base) now typed as T.class_of(Plugin) instead of T.untyped
- raw_hash now typed as T::Hash[String, T.untyped] since YAML produces string keys
@joemsak joemsak marked this pull request as ready for review January 23, 2026 20:40
@joemsak joemsak requested a review from a team January 23, 2026 20:40
Copy link
Contributor

@martinemde martinemde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor quibble, maybe RspecHelpers could be nested under Testing. Your call.

Move RSpecHelpers to CodeTeams::Testing::RSpecHelpers as suggested
in PR review. This better reflects the module hierarchy since
RSpecHelpers is part of the testing utilities.
@joemsak
Copy link
Contributor Author

joemsak commented Jan 27, 2026

Good call, done! Moved RSpecHelpers under Testing namespace → CodeTeams::Testing::RSpecHelpers

@joemsak joemsak merged commit 1313ecd into rubyatscale:main Jan 27, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Triage to Done in Modularity Jan 27, 2026
@joemsak joemsak deleted the jms/move-zp-test-helpers branch January 27, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants